package org.jeecg.modules.job.rms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.job.rms.entity.RmsCompanyPosition;
import org.jeecg.modules.job.rms.mapper.RmsCompanyPositionMapper;
import org.jeecg.modules.job.rms.service.IRmsCompanyPositionService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description: 岗位列表
 * @Author: jeecg-boot
 * @Date:   2022-12-21
 * @Version: V1.0
 */
@Service
public class RmsCompanyPositionServiceImpl extends ServiceImpl<RmsCompanyPositionMapper, RmsCompanyPosition> implements IRmsCompanyPositionService {

    @Resource
    private RmsCompanyPositionMapper companyPositionMapper;

    @Override
    public boolean saveOrUpdatePosition(RmsCompanyPosition param) {
        if (StringUtils.isNotEmpty(param.getSalary())) {
            String[] attr = param.getSalary().split("-");
            if (attr.length == 2) {
                param.setSalaryLow(attr[0]);
            }
        }
        //判断ID是否存在，如果不存在，则新建
        if (param.getId() != null) {
           return this.updateById(param);
        } else {
            return this.save(param);
        }
    }

    @Override
    public RmsCompanyPosition getPositionDetail(RmsCompanyPosition param) {
        return companyPositionMapper.getPositionDetail(param);
    }

    @Override
    public IPage<RmsCompanyPosition> getPositionPageList(Page<RmsCompanyPosition> page, RmsCompanyPosition paramCondition) {
        return companyPositionMapper.getPositionPageList(page,paramCondition);
    }

    @Override
    public IPage<RmsCompanyPosition> getPositionPageListForCompany(Page<RmsCompanyPosition> page, RmsCompanyPosition paramCondition) {
        return companyPositionMapper.getPositionPageListForCompany(page,paramCondition);
    }
}
